<#include "header1.ftl"/>
<style>
    th{
        padding-top: 9px;
    }
    td {
        padding-right: 10px !important;
    }
    a {
        cursor: pointer;
    }

    .goods-introduction{
        overflow:hidden;
        text-overflow:ellipsis;
        display:-webkit-box;
        -webkit-box-orient:vertical;
        -webkit-line-clamp:2;
        word-wrap: break-word;
    }
    .form-group{
        margin-left: 0px !important;
        margin-right: 0px !important;
    }
    .avatar{
        height: 100px;
        width:100px;
        margin-left: 70px;
        margin-top:20px
    }
    #filePicker-2 div:nth-child(2){width:100%!important;height:100%!important;}
    .progress{
        bottom: -35px !important;
    }
    .steps {
        position: relative;
        padding: 25px 0 25px 20px;
    }

    .step,
    .step-line {
        float: left;
    }

    .step {
        display: block;
        width: 50px;
        height: 25px;
        border-radius: 50% !important;
        line-height: 17px;
        text-align: center;
        font-size: 15px;
        border: 2px solid #cdcdcd;
        background: #cdcdcd;
        font: 16px Helvetica Neue,Helvetica,PingFang SC,微软雅黑,Tahoma,Arial,sans-serif;
    }

    .step-line {
        width: 70px;
        position: relative;
        top: 9px;
        height: 5px;
        background-color: #cdcdcd;

    }
    .step-text {

        line-height: 21px;
        color: #fff;
    }
    .step-circle {
        margin: 4px;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: #bfcbd9;
    }
    .step-main {
        font: 14px Helvetica Neue,Helvetica,PingFang SC,微软雅黑,Tahoma,Arial,sans-serif;
        padding: 8px 0;
        display: block;
        width: 144px;
        text-align: center;
        position: relative;
        left: -34px;
        margin-top:10px;
        color: #313131;
    }


    .steps > .step-completed {
        background: #327ab7;
        border-color: #327ab7;
    }

    .step-completed > .step-circle {
        background-color: #2f318e;
    }

    .step-completed.step-line {
        background-color: #327ab7;
    }

</style>
<link href="/assets/plugins/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
<script  src="/assets/plugins/webuploader/0.1.5/webuploader.min.js" type="text/javascript"></script>
<#include "header2.ftl"/>
<div class="main" style="margin-top: 20px;">
    <div class="container">
        <ul class="breadcrumb" id="categoryName">
            <li class="active">个人中心</li>
        </ul>
        <!-- BEGIN SIDEBAR & CONTENT -->
        <div class="row margin-bottom-40">
            <!-- BEGIN SIDEBAR -->
            <div class="sidebar col-md-2 col-sm-3">
                <ul class="list-group margin-bottom-25 sidebar-menu">
                    <li id="myOrder" class="list-group-item clearfix active" style="z-index: 0;"><a href="javascript:;" onclick="changeContent(1)"><i class="fa fa-angle-right"></i> 我的订单</a></li>
                    <li id="myAccount" class="list-group-item clearfix"><a href="javascript:;" onclick="changeContent(2)"><i class="fa fa-angle-right"></i> 我的信息</a></li>
                    <li id="myAddress" class="list-group-item clearfix"><a href="javascript:;" onclick="changeContent(3)"><i class="fa fa-angle-right"></i> 收货地址</a></li>
                    <li id="myAdvice" class="list-group-item clearfix"><a href="javascript:;" onclick="changeContent(4)"><i class="fa fa-angle-right"></i> 意见建议</a></li>
                </ul>
            </div>
            <!-- END SIDEBAR -->

            <!-- BEGIN CONTENT -->
            <div id="myOrderDiv" class="col-md-10 col-sm-9">
                <div class="row margin-bottom-40">
                    <!-- BEGIN CONTENT -->
                    <div class="col-md-12 col-sm-12">
                        <div class="goods-page">
                            <div class="goods-data clearfix" style="padding: 0px">
                                <div class="table-wrapper-responsive" id="goodsTable">
                                </div>

                            </div>
                        </div>
                        <div id="example" style="text-align: center"> <ul id="pageLimit"></ul> </div>
                    </div>
                    <!-- END CONTENT -->
                </div>
            </div>

            <div id="myAccountDiv" class="col-md-10 col-sm-9" hidden>
                <div class="row margin-bottom-40">
                    <!-- BEGIN CONTENT -->
                    <div class="col-md-12 col-sm-12">
                        <div class="goods-page">
                            <div class="goods-data clearfix" style="padding: 0px">
                                <div class="table-wrapper-responsive" id="goodsTable">
                                    <div>
                                        <img id="avatar" src="/assets/pages/img/avatar-default.jpg" class="avatar">

                                    </div>
                                    <form class="form-horizontal form-without-legend">
                                        <div class="form-group">
                                            <label class="col-md-2 control-label" for="userName">用户名: </label>
                                            <div class="col-md-8" style="padding-top: 7px;">
                                                <span id="userName"></span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label" for="email">邮箱: </label>
                                            <div class="col-md-8" style="padding-top: 7px;">
                                                <span id="email"></span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label" for="phone">手机号: </label>
                                            <div class="col-md-8" style="padding-top: 7px;">
                                                <span id="phone"></span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <input type="button" class="btn btn-danger" data-toggle="modal" data-target="#modifyPwdModal" style="margin-left: 70px;margin-right: 15px;" value="修改密码">
                                            <input type="button" class="btn btn-success" data-toggle="modal" data-target="#modifyInfoModal" style="margin-right: 15px;" value="更新个人信息">
                                        </div>

                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- END CONTENT -->
                </div>
            </div>

            <div id="myAdviceDiv" class="col-md-10 col-sm-9" hidden>
                <div class="row margin-bottom-40">
                    <!-- BEGIN CONTENT -->
                    <div class="col-md-12 col-sm-12">
                        <div class="goods-page">
                            <div class="goods-data clearfix" style="padding: 0px">
                                <div class="table-wrapper-responsive" id="adviceTable">
                                </div>
                                <input type="button" class="btn btn-primary" style="margin-top: 25px;margin-right: 45%;" data-toggle="modal" data-target="#adviceModal" value="提建议">
                            </div>


                        </div>

                    </div>
                    <!-- END CONTENT -->
                </div>
            </div>

            <div id="myAddressDiv" class="col-md-10 col-sm-9" hidden>
                <div class="row margin-bottom-40">
                    <!-- BEGIN CONTENT -->
                    <div class="col-md-12 col-sm-12">
                        <div class="goods-page">
                            <div class="goods-data clearfix" style="padding: 0px">
                                <div class="table-wrapper-responsive" id="addressTable">
                                </div>
                                <input type="button" class="btn btn-primary" style="margin-top: 25px;margin-right: 45%;" data-toggle="modal" data-target="#addressModal" value="添加收货地址">
                            </div>


                        </div>

                    </div>
                    <!-- END CONTENT -->
                </div>
            </div>
        </div>

    </div>
        <!-- END CONTENT -->
</div>

<div class="modal fade" id="modifyPwdModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <span class="modal-title" id="myModalLabel">修改密码</span>
            </div>
            <div class="modal-body">
                <form role="form" class="form-horizontal form-without-legend">
                    <div class="form-group">
                        <label class="col-lg-3 control-label" for="first-name"><span style="color:red">*</span>原密码 </label>
                        <div class="col-lg-8">
                            <input type="password" id="oldPassword" class="form-control" placeholder="请输入原密码">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-3 control-label" for="last-name"><span style="color:red">*</span>新密码</label>
                        <div class="col-lg-8">
                            <input type="password" id="password" class="form-control" placeholder="请输入新密码，长度不少于6位">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-3 control-label" for="last-name"><span style="color:red">*</span>确认新密码</label>
                        <div class="col-lg-8">
                            <input type="password" id="password2" class="form-control" placeholder="请再次输入新密码">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="modifyPwd()">提交更改</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>


<div class="modal fade" id="modifyInfoModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <span class="modal-title" id="myModalLabel">更新个人信息</span>
            </div>
            <div class="modal-body" style="padding-top: 0px">
                <form role="form" class="form-horizontal" style="padding-top: 5px">
                    <div class="form-group">
                        <input type="hidden" id="image">
                        <label class="col-lg-3 control-label" for="first-name">头像 </label>
                        <div class="col-lg-8">
                            <div class="uploader-list-container">
                                <div class="queueList">
                                    <div id="dndArea" class="placeholder" style="min-height:130px;background-position-y: 0px;padding-top: 53px">
                                        <div name="filePicker" id="filePicker-2"></div>
                                        <p style="margin-top:-15px">或将图片拖到这里</p>
                                        <p style="color: tomato">不上传则代表不更改原头像</p>
                                    </div>
                                </div>
                                <div class="statusBar" style="display:none;">
                                    <div class="progress"> <span class="text">0%</span> <span class="percentage"></span> </div>
                                    <div class="info"></div>
                                    <div class="btns">
                                        <div id="filePicker2"></div>
                                        <div class="uploadBtn">开始上传</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-3 control-label" for="userName-edit"><span style="color:red">*</span>用户名</label>
                        <div class="col-lg-8">
                            <input type="text" id="userName-edit" class="form-control">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-3 control-label" for="email-edit"><span style="color:red">*</span>邮箱</label>
                        <div class="col-lg-8">
                            <input type="text" id="email-edit" class="form-control">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-3 control-label" for="phone-edit"><span style="color:red">*</span>手机</label>
                        <div class="col-lg-8">
                            <input type="text" id="phone-edit" class="form-control">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="modifyPersonalInfo()">提交更改</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<div class="modal fade" id="adviceModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <span class="modal-title" id="myModalLabel">提建议</span>
            </div>
            <div class="modal-body">
                <form role="form" class="form-horizontal form-without-legend">
                    <div class="form-group">
                        <div class="col-md-12 col-lg-12">
                            <textarea class="form-control" rows="8" id="advice" name="advice" maxlength="500" placeholder="欢迎提出纪念品商城有什么好或不好的地方，或者您有什么想要的纪念品"></textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="addAdvice()">提交</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<div class="modal fade" id="addressModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <span class="modal-title" id="myModalLabel">收货地址</span>
            </div>
            <div class="modal-body">
                <form role="form" class="form-horizontal form-without-legend">
                    <div class="form-group">
                        <input type="hidden" id="addressId">
                        <label class="col-md-3 control-label" for="userName-edit"><span style="color:red">*</span>收货人姓名</label>
                        <div class="col-md-9">
                            <input type="text" id="name" class="form-control" maxlength="20">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="email-edit"><span style="color:red">*</span>手机号码</label>
                        <div class="col-md-9">
                            <input type="text" id="mobilePhone" class="form-control">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="phone-edit"><span style="color:red">*</span>收货地址</label>
                        <div class="col-md-9">
                            <input type="text" id="address" class="form-control" maxlength="80">
                        </div>
                    </div>
                    <div class="checkbox">
                        <label style="padding-left: 90px">
                            <input type="checkbox" id="isDefault">设为默认地址
                        </label>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="addAddress()">提交</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<div class="modal fade" id="detailModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" id="detailDiv">
        <#--<div class="modal-content" style="width: 835px">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <span class="modal-title" id="myModalLabel">订单详情</span>
            </div>
            <div class="modal-body" style="height: 200px" id="detailDiv">

            </div>

        </div>-->
    </div><!-- /.modal -->
</div>

<#include "footer1.ftl"/>
<script type="text/html" id="emptyTemplate">
<div style="background-color: white;text-align: center;height: 400px;vertical-align: middle">
    <img src="/assets/pages/img/no_goods.png" style="height: 200px;margin-top: 50px;">
    <p style="margin-top: 10px">你还没在商城下过单哦，赶紧去逛逛吧~~</p>
</div>
</script>

<script type="text/html" id="detailTemplate">
    <div class="modal-content" style="width: {{width}}px">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <span class="modal-title" id="myModalLabel">订单详情</span>
        </div>
        <div class="modal-body" style="height: 200px">
            <div class="steps">
                <div class="step-line step-completed"></div>

                <div class="step step-completed">
                    <div class="step-text">下单</div>
                    <div class="step-main">{{order.createTimeStr}}</div>
                </div>

                <div class="step-line step-completed"></div>

                {{if order.status == 1}}
                <div class="step-line"></div>
                <div class="step">
                    <div class="step-text">付款</div>
                    <div class="step-main"></div>
                </div>
                <div class="step-line"></div>
                <div class="step-line"></div>
                <div class="step">
                    <div class="step-text">配货</div>
                    <div class="step-main"></div>
                </div>
                <div class="step-line"></div>
                <div class="step-line"></div>
                <div class="step" style="width:85px">
                    <div class="step-text">交易成功</div>
                    <div class="step-main"></div>
                </div>
                <div class="step-line"></div>
                {{/if}}

                {{if order.status == 2}}
                <div class="step-line step-completed"></div>
                <div class="step step-completed">
                    {{if order.payBalance != null && order.payBalance != '' && order.payBalance != 0}}
                    <div class="step-text">审批</div>
                    <div class="step-main">{{order.createTimeStr}}</div>
                    {{else}}
                    <div class="step-text">付款</div>
                    <div class="step-main">{{order.payTimeStr}}</div>
                    {{/if}}
                </div>
                <div class="step-line step-completed"></div>
                <div class="step-line step-completed"></div>
                <div class="step step-completed">
                    <div class="step-text">配货</div>
                    <div class="step-main">{{order.payTimeStr}}
                        {{if order.pickingDays != null && order.pickingDays != 0}}
                            </br><span style="color:blue">(预计{{order.pickingDays}}天内完成配货)</span>
                        {{/if}}
                    </div>
                </div>
                <div class="step-line step-completed"></div>
                <div class="step-line"></div>
                <div class="step" style="width:85px">
                    <div class="step-text">交易成功</div>
                    <div class="step-main"></div>
                </div>
                <div class="step-line"></div>
                {{/if}}

                {{if order.status == 3}}
                <div class="step-line step-completed"></div>
                <div class="step step-completed">
                    <div class="step-text">付款</div>
                    <div class="step-main">{{order.payTimeStr}}</div>
                </div>
                <div class="step-line step-completed"></div>
                <div class="step-line step-completed"></div>
                <div class="step step-completed">
                    <div class="step-text step-completed">配货</div>
                    <div class="step-main">{{order.payTimeStr}}</div>
                </div>
                <div class="step-line step-completed"></div>
                <div class="step-line step-completed"></div>
                <div class="step step-completed" style="width:85px">
                    <div class="step-text">交易成功</div>
                    <div class="step-main">{{order.finishTimeStr}}</div>
                </div>
                <div class="step-line step-completed"></div>
                {{/if}}

                {{if order.status == 4}}
                <div class="step-line step-completed"></div>
                <div class="step step-completed">
                    <div class="step-text">取消</div>
                    <div class="step-main">{{order.finishTimeStr}}</div>
                </div>
                <div class="step-line step-completed"></div>
                {{/if}}

                {{if order.status == 5}}
                {{if order.payTimeStr != null}}
                <div class="step-line step-completed"></div>
                <div class="step step-completed">
                    <div class="step-text">付款</div>
                    <div class="step-main">{{order.payTimeStr}}</div>
                </div>
                <div class="step-line step-completed"></div>
                {{/if}}
                <div class="step-line step-completed"></div>
                <div class="step step-completed">
                    <div class="step-text">无效</div>
                    <div class="step-main">{{order.finishTimeStr}}</div>
                </div>
                <div class="step-line step-completed"></div>
                {{/if}}

                {{if order.status == 7}}
                <div class="step-line step-completed"></div>
                <div class="step step-completed">
                    <div class="step-text">付款</div>
                    <div class="step-main">{{order.payTimeStr}}</div>
                </div>
                <div class="step-line step-completed"></div>
                <div class="step-line step-completed"></div>
                <div class="step step-completed">
                    <div class="step-text step-completed">配货</div>
                    <div class="step-main">{{order.payTimeStr}}
                        {{if order.pickingDays != null && order.pickingDays != 0}}
                        </br><span style="color:blue">(预计{{order.pickingDays}}天内完成配货)</span>
                        {{/if}}
                    </div>
                </div>
                <div class="step-line step-completed"></div>
                <div class="step-line"></div>
                <div class="step" style="width:85px">
                    <div class="step-text">交易成功</div>
                    <div class="step-main"></div>
                </div>
                <div class="step-line"></div>
                {{/if}}

                {{if order.status == 8}}
                <div class="step-line step-completed"></div>
                <div class="step step-completed">
                    <div class="step-text">审批</div>
                    <div class="step-main">{{order.createTimeStr}}</div>
                </div>
                <div class="step-line step-completed"></div>
                <div class="step-line step-completed"></div>
                <div class="step step-completed" style="width:100px">
                    <div class="step-text step-completed">审批未通过</div>
                    <div class="step-main">{{order.finishTimeStr}}</div>
                </div>
                <div class="step-line step-completed"></div>
                {{/if}}

                {{if order.status == 0 || order.status == 9}}
                <div class="step-line step-completed"></div>
                <div class="step step-completed">
                    <div class="step-text">审批</div>
                    <div class="step-main">{{order.createTimeStr}}</div>
                </div>
                <div class="step-line step-completed"></div>
                <div class="step-line"></div>
                <div class="step">
                    <div class="step-text">配货</div>
                    <div class="step-main"></div>
                </div>
                <div class="step-line"></div>
                <div class="step-line"></div>
                <div class="step" style="width:85px">
                    <div class="step-text">交易成功</div>
                    <div class="step-main"></div>
                </div>
                <div class="step-line"></div>
                {{/if}}

            </div>
        </div>
    </div>

</script>


<script type="text/html" id="orderTemplate">
    {{each goodsList order index}}
    <table summary="Shopping cart">
        <tr style="background-color: #eee;">
            <th class="goods-page-image" style="padding-left: 15px;width:136px">{{order.createTime}}</th>
            <th class="goods-page-description" style="padding-left: 40px;width:270px">订单号：{{order.orderNo}}</th>
            <th class="goods-page-quantity" style="width:10px">数量</th>
            <th class="goods-page-price" style="width:10px">单价</th>
            <th class="goods-page-total" style="padding-left: 15px;">实付金额</th>
            <th class="goods-page-total" >状态</th>
            <th class="goods-page-total" >操作</th>
        </tr>
        {{each order.orderItemList goods goodsIndex}}
        <tr>
            <td class="goods-page-image" style="padding-left: 15px;width:120px>
                <a href="javascript:;"><img src="{{goods.picPath}}" style="width:75px;height: 65px"></a>
            </td>
            <td class="goods-page-description" >
                <h3><a href="?itemId={{goods.itemId}}" target="_blank">{{goods.title}}</a></h3>
                <p class="goods-introduction">{{goods.introduction}}</p>
            </td>

            <td class="goods-page-quantity" >
                <div class="product-quantity">
                    <input id="product-quantity" type="text" value="{{goods.num}}" readonly class="form-control input-sm">
                </div>
            </td>
            <td class="goods-page-price" style="border-right: 1px solid #efefef;">
                <strong><span>￥</span>{{goods.price}}</strong>
            </td>
            {{if goodsIndex == 0}}
            <td class="goods-page-total" style="padding-left: 15px;">
                <strong><span>￥</span>{{order.payment}}</strong>
            </td>
            <td class="goods-page-price">
                <span>
                    {{if order.status == 0 || order.status == 9}}
                        待审批
                    {{else if order.status == 1}}
                        待付款
                    {{else if order.status == 2}}
                        配货中
                    {{else if order.status == 3}}
                        已完成
                    {{else if order.status == 4}}
                        已取消
                    {{else if order.status == 5}}
                        无效
                    {{else if order.status == 6}}
                        退货
                    {{else if order.status == 7}}
                        部分发货
                    {{else if order.status == 8}}
                        审批未通过
                    {{/if}}
                </span>
            </td>
            <td class="goods-page-price">
                <div class="f-fl oper j-oper">
                    {{if order.status == 0 || order.status == 9}}
                    <a onclick="detail('{{order.orderId}}')"><span class="f-cb re-buy j-re-buy" >查看详情</span></a><br/>
                    <a onclick="cancelOrder('{{order.orderId}}')"><span class="f-cb re-buy j-re-buy" >取消订单</span></a>
                    {{else if order.status == 2 || order.status == 7}}
                    <a onclick="detail('{{order.orderId}}')"><span class="f-cb re-buy j-re-buy" >查看详情</span></a><br/>
                    {{else if order.status == 1}}
                    <a onclick="detail('{{order.orderId}}')"><span class="f-cb re-buy j-re-buy" >查看详情</span></a><br/>
                    <a href="/order/payOrder?orderId={{order.orderId}}"><span class="f-cb re-buy j-re-buy" >去付款</span></a><br/>
                    <a onclick="cancelOrder('{{order.orderId}}')"><span class="f-cb re-buy j-re-buy" >取消订单</span></a>
                    {{else if order.status == 3}}
                    <a onclick="detail('{{order.orderId}}')"><span class="f-cb re-buy j-re-buy" >查看详情</span></a><br/>
                    <a onclick="delOrder('{{order.orderId}}')"><span class="f-cb re-buy j-re-buy" >删除订单</span></a>
                    {{else if order.status == 4 || order.status == 5 || order.status == 6 || order.status == 8}}
                    <a onclick="detail('{{order.orderId}}')"><span class="f-cb re-buy j-re-buy" >查看详情</span></a><br/>
                    <a onclick="reBuy('{{order.orderId}}')"><span class="f-cb re-buy j-re-buy" >重新购买</span></a><br/>
                    <a onclick="delOrder('{{order.orderId}}')"><span class="f-cb re-buy j-re-buy" >删除订单</span></a>
                    {{/if}}
                </div>
            </td>
            {{/if}}
            {{if goodsIndex == order.orderItemList.length-1}}
                <td></td><td></td><td></td>
            {{/if}}
        </tr>
        {{/each}}
    </table>
    {{/each}}
</script>

<script type="text/html" id="adviceTemplate">
    {{if adviceList != null && adviceList.length > 0}}
    <table summary="Shopping cart">
        <tr style="background-color: #eee;">
            <th class="goods-page-total" style="text-align: center;width: 50%;">我的建议</th>
            <th class="goods-page-total" style="text-align: center;width: 30%;">回复</th>
            <th class="goods-page-total" style="text-align: center;width: 20%;">操作</th>
        </tr>
        {{each adviceList advice index}}
        <tr>
            <td class="goods-page-image" style="width:50%;text-align: center;">
                  <p>{{advice.advice}}</p>
            </td>
            <td class="goods-page-description" style="width:30%;text-align: center;">
                <p>{{if advice.reply != null}}{{advice.reply}}{{else}}暂无回复{{/if}}</p>
            </td>
            <td style="width:20%;text-align: center;">
            <a onclick="delAdvice('{{advice.id}}')"><span class="f-cb re-buy j-re-buy" id="auto-id-1568166392565">删除</span></a>
            </td>
        </tr>
        {{/each}}
    </table>


    {{else}}
    <div style="background-color: white;height: 50px;vertical-align: middle">
        <p style="margin-top: 10px;text-indent: 2em">如果您在使用纪念品商城时，有什么好或不好的地方，或者有什么想要的纪念品，请大声说出来！我们会关注您的反馈，不断优化产品，为您提供更好的服务！</p>
    </div>
    {{/if}}

</script>

<script type="text/html" id="addressTemplate">
    <table summary="Shopping cart">
        <tr style="background-color: #eee;">
            <th class="goods-page-image" style="text-align: center;width: 15%;">收货人姓名</th>
            <th class="goods-page-total" style="text-align: center;width: 15%;">手机号码</th>
            <th class="goods-page-total" style="text-align: center;width: 55%;">收货地址</th>
            <th class="goods-page-total" style="text-align: center;width: 15%;">操作</th>
        </tr>
        {{if addressList != null && addressList.length > 0}}
        {{each addressList address index}}
        <tr>
            <td class="goods-page-description" style="width:15%;text-align: center;">
                <p>{{address.name}}</p>
            </td>
            <td class="goods-page-description" style="width:15%;text-align: center;">
                <p>{{address.phone}}</p>
            </td>
            <td class="goods-page-description" style="width:55%;text-align: center;">
                <p>{{address.address}}{{if address.isDefault}}（默认地址）{{/if}}</p>
            </td>
            <td style="width:15%;text-align: center;">
                <a onclick="editAddress('{{address.id}}','{{address.name}}','{{address.phone}}','{{address.address}}','{{address.isDefault}}')"><span class="f-cb re-buy j-re-buy">编辑</span></a>
                <a style="margin-left: 5px" onclick="delAddress('{{address.id}}')"><span class="f-cb re-buy j-re-buy" id="auto-id-1568166392565">删除</span></a>
            </td>
        </tr>
        {{/each}}
        {{else}}
        <td colspan="4" style="text-align: center;">暂无数据</td>
        {{/if}}
    </table>
</script>

<script type="text/javascript">
    function getOrderList(currentPage){
        var index = layer.load(3);
        $.get("/order/orderList",{userId:2,page:currentPage},function (data) {
            layer.close(index);
            var result = data.result;
            if (result.total > 0){
                var html = template('orderTemplate',{goodsList:result.data});
                $("#goodsTable").html(html);
                var totalPages = result.total%5 == 0?result.total/5 : result.total/5+1;
                if (currentPage > totalPages){
                    currentPage = totalPages;
                }
                $('#pageLimit').bootstrapPaginator({
                    currentPage: currentPage,//当前页。
                    totalPages: totalPages,//总页数。
                    size:"normal",//应该是页眉的大小。
                    bootstrapMajorVersion: 3,//bootstrap的版本要求。
                    alignment:"right",
                    numberOfPages:5,//显示的页数
                    itemTexts: function (type, page, current) {//如下的代码是将页眉显示的中文显示我们自定义的中文。
                        switch (type) {
                            case "first": return "首页";
                            case "prev": return "上一页";
                            case "next": return "下一页";
                            case "last": return "末页";
                            case "page": return page;
                        }
                    },
                    onPageClicked: function (event, originalEvent, type, page) {//给每个页眉绑定一个事件，其实就是ajax请求，其中page变量为当前点击的页上的数字。
                        var index = layer.load(3);
                        $.get("/order/orderList",{userId:2,page:page},function (data) {
                            window.scrollTo(0,$("#goodsDiv").offset().top);
                            layer.close(index);
                            var html = template('orderTemplate',{goodsList:data.result.data});
                            $("#goodsTable").html(html);
                        })
                    }
                });
            } else{
                var html = template('emptyTemplate');
                $("#goodsTable").html(html);
                $("#example").hide();
            }

        })

    }

    function getPersonalInfo(){
        $.post('/member/getPersonalInfo',function (data) {
            if (data.success){
                var result = data.result;
                $("#userName").html(result.username);
                $("#email").html(result.email);
                $("#phone").html(result.phone);
                $("#userName-edit").val(result.username);
                $("#email-edit").val(result.email);
                $("#phone-edit").val(result.phone);
                if (result.image){
                    $("#avatar").attr("src",result.image);
                }
            }
        })
    }

    function getAdvice(){
        $.post('/advice/list',function (data) {
            var html = template('adviceTemplate',{adviceList:data});
            $("#adviceTable").html(html);
        })
    }

    function getAddressList(){
        $.get('/address/list',function (data) {
            var html = template('addressTemplate',{addressList:data.result});
            $("#addressTable").html(html);
        })
    }

    $(function () {
        getOrderList(1);
        getPersonalInfo();
        getAdvice();
        getAddressList();
        var $wrap = $('.uploader-list-container'),

            // 图片容器
            $queue = $('<ul class="filelist"></ul>')
                .appendTo($wrap.find('.queueList')),

            // 状态栏，包括进度和控制按钮
            $statusBar = $wrap.find('.statusBar'),

            // 文件总体选择信息。
            $info = $statusBar.find('.info'),

            // 上传按钮
            $upload = $wrap.find('.uploadBtn'),

            // 没选择文件之前的内容。
            $placeHolder = $wrap.find('.placeholder'),

            $progress = $statusBar.find('.progress').hide(),

            // 添加的文件数量
            fileCount = 0,

            // 添加的文件总大小
            fileSize = 0,

            // 优化retina, 在retina下这个值是2
            ratio = window.devicePixelRatio || 1,

            // 缩略图大小
            thumbnailWidth = 110 * ratio,
            thumbnailHeight = 110 * ratio,

            // 可能有pedding, ready, uploading, confirm, done.
            state = 'pedding',

            // 所有文件的进度信息，key为file id
            percentages = {},
            // 判断浏览器是否支持图片的base64
            isSupportBase64 = (function () {
                var data = new Image();
                var support = true;
                data.onload = data.onerror = function () {
                    if (this.width != 1 || this.height != 1) {
                        support = false;
                    }
                }
                data.src = "";
                return support;
            })(),

            // 检测是否已经安装flash，检测flash的版本
            flashVersion = (function () {
                var version;

                try {
                    version = navigator.plugins['Shockwave Flash'];
                    version = version.description;
                } catch (ex) {
                    try {
                        version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash')
                            .GetVariable('$version');
                    } catch (ex2) {
                        version = '0.0';
                    }
                }
                version = version.match(/\d+/g);
                return parseFloat(version[0] + '.' + version[1], 10);
            })(),

            supportTransition = (function () {
                var s = document.createElement('p').style,
                    r = 'transition' in s ||
                        'WebkitTransition' in s ||
                        'MozTransition' in s ||
                        'msTransition' in s ||
                        'OTransition' in s;
                s = null;
                return r;
            })(),

            // WebUploader实例
            uploader;

        if (!WebUploader.Uploader.support('flash') && WebUploader.browser.ie) {

            // flash 安装了但是版本过低。
            if (flashVersion) {
                (function (container) {
                    window['expressinstallcallback'] = function (state) {
                        switch (state) {
                            case 'Download.Cancelled':
                                alert('您取消了更新！')
                                break;

                            case 'Download.Failed':
                                alert('安装失败')
                                break;

                            default:
                                alert('安装已成功，请刷新！');
                                break;
                        }
                        delete window['expressinstallcallback'];
                    };

                    var swf = 'expressInstall.swf';
                    // insert flash object
                    var html = '<object type="application/' +
                        'x-shockwave-flash" data="' + swf + '" ';

                    if (WebUploader.browser.ie) {
                        html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
                    }

                    html += 'width="100%" height="100%" style="outline:0">' +
                        '<param name="movie" value="' + swf + '" />' +
                        '<param name="wmode" value="transparent" />' +
                        '<param name="allowscriptaccess" value="always" />' +
                        '</object>';

                    container.html(html);

                })($wrap);

                // 压根就没有安转。
            } else {
                $wrap.html('<a href="http://www.adobe.com/go/getflashplayer" target="_blank" border="0"><img alt="get flash player" src="http://www.adobe.com/macromedia/style_guide/images/160x41_Get_Flash_Player.jpg" /></a>');
            }

            return;
        } else if (!WebUploader.Uploader.support()) {
            alert('Web Uploader 不支持您的浏览器！');
            return;
        }

        // 实例化
        uploader = WebUploader.create({
            pick: {
                id: '#filePicker-2',
                label: '点击选择图片'
            },
            formData: {
                uid: 123
            },
            dnd: '#dndArea',
            paste: '#uploader',
            swf: 'lib/webuploader/0.1.5/Uploader.swf',
            chunked: false,
            chunkSize: 512 * 1024,
            server: '/member/imgaeUpload',
            // runtimeOrder: 'flash',

            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,bmp,png',
                //mimeTypes: 'image/*'
            },

            // 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候，把图片打开。
            disableGlobalDnd: true,
            fileNumLimit: 1,
            fileSizeLimit: 5 * 1024 * 1024,    // 5 M
            fileSingleSizeLimit: 5 * 1024 * 1024    // 5 M
        });

        // 拖拽时不接受 js, txt 文件。
        uploader.on('dndAccept', function (items) {
            var denied = false,
                len = items.length,
                i = 0,
                // 修改js类型
                unAllowed = 'text/plain;application/javascript ';

            for (; i < len; i++) {
                // 如果在列表里面
                if (~unAllowed.indexOf(items[i].type)) {
                    denied = true;
                    break;
                }
            }

            return !denied;
        });

        uploader.on('dialogOpen', function () {
            console.log('here');
        });

        uploader.on('ready', function () {
            window.uploader = uploader;
        });

        // 当有文件添加进来时执行，负责view的创建
        function addFile(file) {
            var $li = $('<li id="' + file.id + '">' +
                '<p class="title">' + file.name + '</p>' +
                '<p class="imgWrap"></p>' +
                '<p class="progress"><span></span></p>' +
                '</li>'),

                $btns = $('<div class="file-panel">' +
                    '<span class="cancel">删除</span>' +
                    '<span class="rotateRight">向右旋转</span>' +
                    '<span class="rotateLeft">向左旋转</span></div>').appendTo($li),
                $prgress = $li.find('p.progress span'),
                $wrap = $li.find('p.imgWrap'),
                $info = $('<p class="error"></p>'),

                showError = function (code) {
                    switch (code) {
                        case 'exceed_size':
                            text = '文件大小超出';
                            break;

                        case 'interrupt':
                            text = '上传暂停';
                            break;

                        default:
                            text = '上传失败，请重试';
                            break;
                    }

                    $info.text(text).appendTo($li);
                };

            if (file.getStatus() === 'invalid') {
                showError(file.statusText);
            } else {
                // @todo lazyload
                $wrap.text('预览中');
                uploader.makeThumb(file, function (error, src) {
                    var img;

                    if (error) {
                        $wrap.text('不能预览');
                        return;
                    }

                    if (isSupportBase64) {
                        img = $('<img src="' + src + '">');
                        $wrap.empty().append(img);
                    } else {
                        $.ajax('lib/webuploader/0.1.5/server/preview.php', {
                            method: 'POST',
                            data: src,
                            dataType: 'json'
                        }).done(function (response) {
                            if (response.result) {
                                img = $('<img src="' + response.result + '">');
                                $wrap.empty().append(img);
                            } else {
                                $wrap.text("预览出错");
                            }
                        });
                    }
                }, thumbnailWidth, thumbnailHeight);

                percentages[file.id] = [file.size, 0];
                file.rotation = 0;
            }

            file.on('statuschange', function (cur, prev) {
                if (prev === 'progress') {
                    $prgress.hide().width(0);
                } else if (prev === 'queued') {
                    $li.off('mouseenter mouseleave');
                    $btns.remove();
                }

                // 成功
                if (cur === 'error' || cur === 'invalid') {
                    console.log(file.statusText);
                    showError(file.statusText);
                    percentages[file.id][1] = 1;
                } else if (cur === 'interrupt') {
                    showError('interrupt');
                } else if (cur === 'queued') {
                    percentages[file.id][1] = 0;
                } else if (cur === 'progress') {
                    $info.remove();
                    $prgress.css('display', 'block');
                } else if (cur === 'complete') {
                    $li.append('<span class="success"></span>');
                }

                $li.removeClass('state-' + prev).addClass('state-' + cur);
            });

            $li.on('mouseenter', function () {
                $btns.stop().animate({height: 30});
            });

            $li.on('mouseleave', function () {
                $btns.stop().animate({height: 0});
            });

            $btns.on('click', 'span', function () {
                var index = $(this).index(),
                    deg;

                switch (index) {
                    case 0:
                        uploader.removeFile(file);
                        return;

                    case 1:
                        file.rotation += 90;
                        break;

                    case 2:
                        file.rotation -= 90;
                        break;
                }

                if (supportTransition) {
                    deg = 'rotate(' + file.rotation + 'deg)';
                    $wrap.css({
                        '-webkit-transform': deg,
                        '-mos-transform': deg,
                        '-o-transform': deg,
                        'transform': deg
                    });
                } else {
                    $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
                }


            });

            $li.appendTo($queue);
        }

        // 负责view的销毁
        function removeFile(file) {
            var $li = $('#' + file.id);

            delete percentages[file.id];
            updateTotalProgress();
            $li.off().find('.file-panel').off().end().remove();
        }

        function updateTotalProgress() {
            var loaded = 0,
                total = 0,
                spans = $progress.children(),
                percent;

            $.each(percentages, function (k, v) {
                total += v[0];
                loaded += v[0] * v[1];
            });

            percent = total ? loaded / total : 0;


            spans.eq(0).text(Math.round(percent * 100) + '%');
            spans.eq(1).css('width', Math.round(percent * 100) + '%');
            updateStatus();
        }

        function updateStatus() {
            var text = '', stats;

            if (state === 'ready') {
                text = '选中' + fileCount + '张图片，共' +
                    WebUploader.formatSize(fileSize) + '。';
            } else if (state === 'confirm') {
                stats = uploader.getStats();
                if (stats.uploadFailNum) {
                    text = '已成功上传' + stats.successNum + '张照片，' +
                        stats.uploadFailNum + '张照片上传失败，<a class="retry" href="#">重新上传</a>失败图片或<a class="ignore" href="#">忽略</a>'
                }

            } else {
                stats = uploader.getStats();
                text = '上传成功';

                if (stats.uploadFailNum) {
                    text = '上传失败';
                }
            }

            $info.html(text);
        }

        function setState(val) {
            var file, stats;

            if (val === state) {
                return;
            }

            $upload.removeClass('state-' + state);
            $upload.addClass('state-' + val);
            state = val;

            switch (state) {
                case 'pedding':
                    $placeHolder.removeClass('element-invisible');
                    $queue.hide();
                    $statusBar.addClass('element-invisible');
                    uploader.refresh();
                    break;

                case 'ready':
                    $placeHolder.addClass('element-invisible');
                    $('#filePicker2').removeClass('element-invisible');
                    $queue.show();
                    $statusBar.removeClass('element-invisible');
                    uploader.refresh();
                    break;

                case 'uploading':
                    $('#filePicker2').addClass('element-invisible');
                    $progress.show();
                    $upload.text('暂停上传');
                    break;

                case 'paused':
                    $progress.show();
                    $upload.text('继续上传');
                    break;

                case 'confirm':
                    $progress.hide();
                    $('#filePicker2').removeClass('element-invisible');
                    $upload.text('开始上传');

                    stats = uploader.getStats();
                    if (stats.successNum && !stats.uploadFailNum) {
                        setState('finish');
                        return;
                    }
                    break;
                case 'finish':
                    stats = uploader.getStats();
                    if (stats.successNum) {
                        //alert('上传成功');
                    } else {
                        // 没有成功的图片，重设
                        state = 'done';
                        location.reload();
                    }
                    break;
            }

            updateStatus();
        }

        uploader.onUploadProgress = function (file, percentage) {
            var $li = $('#' + file.id),
                $percent = $li.find('.progress span');

            $percent.css('width', percentage * 100 + '%');
            percentages[file.id][1] = percentage;
            updateTotalProgress();
        };

        uploader.onFileQueued = function (file) {
            fileCount++;
            fileSize += file.size;

            if (fileCount === 1) {
                $placeHolder.addClass('element-invisible');
                $statusBar.show();
            }

            addFile(file);
            setState('ready');
            updateTotalProgress();
        };

        uploader.onFileDequeued = function (file) {
            fileCount--;
            fileSize -= file.size;

            if (!fileCount) {
                setState('pedding');
            }

            removeFile(file);
            updateTotalProgress();

        };
        // 文件上传成功
        uploader.on( 'uploadSuccess', function( file,data ) {

            if(data.success==true){
                $("#image").val(data.result);
            }else{
                alert("上传失败:"+data.message)
            }

        });



        uploader.on('all', function (type) {
            var stats;
            switch (type) {
                case 'uploadFinished':
                    setState('confirm');
                    break;

                case 'startUpload':
                    setState('uploading');
                    break;

                case 'stopUpload':
                    setState('paused');
                    break;

            }
        });

        uploader.onError = function (code) {
            if(code=="Q_TYPE_DENIED"){
                alert("文件类型不支持，仅支持gif,jpg,jpeg,bmp,png格式图片");
            }else if(code=="F_DUPLICATE"){
                alert("文件已选中，请勿重复上传");
            }else if(code="F_EXCEED_SIZE"){
                alert("只能上传一张图片，单张图片大小不得超过5MB");
            } else{
                alert('Error: ' + code);
            }

        };

        $upload.on('click', function () {
            if ($(this).hasClass('disabled')) {
                return false;
            }

            if (state === 'ready') {
                uploader.upload();
            } else if (state === 'paused') {
                uploader.upload();
            } else if (state === 'uploading') {
                uploader.stop();
            }
        });

        $info.on('click', '.retry', function () {
            uploader.retry();
        });

        $info.on('click', '.ignore', function () {
            alert('已忽略');
        });

        $upload.addClass('state-' + state);
        updateTotalProgress();
    })

    function detail(id) {
        $.post('/order/detail',{orderId:id},function (data) {
            var order = data.result;
            var width;
            if (order.status == 0 || order.status == 1 || order.status == 2 || order.status == 3 || order.status == 7 || order.status == 9){
                width = 860;
            } else if (order.status == 4) {
                width = 500;
            }else if(order.status == 5){
                if(order.payTimeStr != null){
                    width = 650;
                }else{
                    width = 500;
                }

            }else if(order.status == 8){
                width = 690;
            }else{
                width = 860;
            }
            var html = template('detailTemplate',{order:order,width:width});
            $("#detailDiv").html(html);
        })
        $('#detailModal').modal('show');
    }

    function addAddress() {
        var id = $("#addressId").val();
        var name = $("#name").val();
        var phone = $("#mobilePhone").val();
        var address = $("#address").val();
        if (name == ''){
            layer.msg('收货人姓名不能为空');
            return;
        }
        if (phone == ''){
            layer.msg('手机号码不能为空');
            return;
        }
        if (!((phone.length == 11 && /^1[3456789]\d{9}$/.test(phone))|| (phone.length == 8 && /^(5|6|8|9)\d{7}$/.test(phone)))) {
            layer.msg('请输入有效的手机号码');
            return;
        }
        if (address == ''){
            layer.msg('收货地址不能为空');
            return;
        }
        var isDefault = 0;
        if ($("#isDefault").attr("checked")){
            isDefault =1;
        }

        $.post('/address/update',{id:id,name:name,phone:phone, address:address,isDefault:isDefault},function (data) {
            if(data.success){
                if(id){
                    layer.msg('编辑成功');
                }else{
                    layer.msg('添加成功');
                }
                getAddressList();
                $('#addressModal').modal('hide');
                $("#addressId").val('');
                $("#name").val('');
                $("#mobilePhone").val('');
                $("#address").val('');
                $("#isDefault").attr("checked",false);
            }else{
                layer.msg('操作失败')
            }

        })
    }

    function editAddress(id,name,phone,address,isDefault) {
        $("#addressId").val(id);
        $("#name").val(name);
        $("#mobilePhone").val(phone);
        $("#address").val(address);
        if (isDefault == 'true'){
            $("#isDefault").attr("checked",true);
        }else{
            $("#isDefault").attr("checked",false);
        }
        $('#addressModal').modal('show');
    }

    function delAddress(id){
        layer.confirm('确认要删除吗？',{icon:0},function(){
            $.post('/address/del',{id:id},function (data) {
                if (data.success){
                    getAddressList();
                    layer.msg('删除成功!');
                }
            })
        });
    }

    function addAdvice(){
        var advice = $("#advice").val();
        $.post('/advice/add',{advice:advice},function (data) {
            if (data.success){
                getAdvice();
                layer.msg("提交成功");
                $("#advice").val('');
                $('#adviceModal').modal('hide');
            }else{
                layer.msg(data.message);
            }
        })
    }

    function delAdvice(id){
        layer.confirm('确认要删除吗？',{icon:0},function(){
            $.post('/advice/del',{id:id},function (data) {
                if (data.success){
                    getAdvice();
                    layer.msg('删除成功!');
                }
            })
        });
    }


    function modifyPwd() {
        var oldPassword = $("#oldPassword").val();
        var password = $("#password").val();
        var password2 = $("#password2").val();
        if (oldPassword == ''){
            layer.msg('请输入原密码');
            return;
        }
        if (password == ''){
            layer.msg('请输入新密码');
            return;
        }
        if (password != '' && password.length < 6){
            layer.msg('新密码长度不能少于6位');
            return;
        }
        if (password2 == ''){
            layer.msg('请确认新密码');
            return;
        }
        if(password2 != password){
            layer.msg('两次输入密码不一致');
            return;
        }

        $.post('/member/modifyPassword',{oldPassword:oldPassword,password:password},function (data) {
            if (data.success){
                layer.msg("修改成功");
                $('#modifyPwdModal').modal('hide')
            }else{
                layer.msg(data.message);
            }
        })

    }

    function modifyPersonalInfo() {
        var image = $("#image").val();
        var userName = $("#userName-edit").val();
        var email = $("#email-edit").val();
        var phone = $("#phone-edit").val();
        if (userName == ''){
            layer.msg('用户名不能为空');
            return;
        }
        if (email == ''){
            layer.msg('邮箱不能为空');
            return;
        }
        if (!/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(email)){
            layer.msg('请输入有效的邮箱地址');
            return;
        }
        if (phone == ''){
            layer.msg('手机号不能为空');
            return;
        }
        if (!((phone.length == 11 && /^1[3456789]\d{9}$/.test(phone))|| (phone.length == 8 && /^(5|6|8|9)\d{7}$/.test(phone)))) {
            layer.msg('请输入有效的手机号码');
            return;
        }

        $.post('/member/update',{username:userName,email:email, phone:phone, image:image},function (data) {
            if(data.success){
                layer.msg('更新成功');
                getPersonalInfo();
                $('#modifyInfoModal').modal('hide')
            }else{
                layer.msg('更新失败')
            }

        })

    }

    function delOrder(id){
        layer.confirm('确认要删除该订单吗？',{icon:0},function(){
            $.post('/order/delOrder',{orderId:id},function (data) {
                if (data.success){
                    layer.msg('删除成功!');
                    var currentPage = $('#pageLimit').bootstrapPaginator("getPages").current;
                    getOrderList(currentPage);
                }
            })
        });
    }

    function cancelOrder(id){
        layer.confirm('确认要取消该订单吗？',{icon:0},function(){
            $.post('/order/cancelOrder',{orderId:id},function (data) {
                if (data.success){
                    layer.msg('取消成功!');
                    var currentPage = $('#pageLimit').bootstrapPaginator("getPages").current;
                    getOrderList(currentPage);
                }
            })
        });
    }

    function reBuy(id){
        var index = layer.load(3);
        $.post('/order/reBuy',{orderId:id},function (data) {
            if (data.success){
                layer.close(index);
                $("#cartDiv").load("/index/cart");
                layer.msg('商品已成功加入购物车!');
            }
        })
    }

    function changeContent(index){
        if (index == 1){
            $(".list-group-item").removeClass('active');
            $("#myOrder").addClass('active');
            $("#myOrderDiv").show();

            $("#myAdviceDiv").hide();
            $("#myAccountDiv").hide();
            $("#myAddressDiv").hide();
        } else if (index == 2) {
            $(".list-group-item").removeClass('active');
            $("#myAccount").addClass('active');
            $("#myAccountDiv").show();

            $("#myAdviceDiv").hide();
            $("#myOrderDiv").hide();
            $("#myAddressDiv").hide();
        }else if (index == 3){
            $(".list-group-item").removeClass('active');
            $("#myAddress").addClass('active');
            $("#myAddressDiv").show();

            $("#myAdviceDiv").hide();
            $("#myOrderDiv").hide();
            $("#myAccountDiv").hide();
        }else{
            $(".list-group-item").removeClass('active');
            $("#myAdvice").addClass('active');
            $("#myAdviceDiv").show();

            $("#myOrderDiv").hide();
            $("#myAccountDiv").hide();
            $("#myAddressDiv").hide();
        }
    }
</script>
<#include "footer2.ftl"/>
